﻿using System;
using System.Collections.Generic;
using System.Text;
using KKSG;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	// Token: 0x020009A8 RID: 2472
	internal class XChatDocument : XDocComponent
	{
		// Token: 0x17002D31 RID: 11569
		// (get) Token: 0x0600957A RID: 38266 RVA: 0x00165958 File Offset: 0x00163B58
		public override uint ID
		{
			get
			{
				return XChatDocument.uuID;
			}
		}

		// Token: 0x17002D32 RID: 11570
		// (get) Token: 0x0600957B RID: 38267 RVA: 0x00165970 File Offset: 0x00163B70
		// (set) Token: 0x0600957C RID: 38268 RVA: 0x00165987 File Offset: 0x00163B87
		public XChatView ChatView
		{
			get
			{
				return DlgBase<XChatView, XChatBehaviour>.singleton;
			}
			set
			{
				this._XChatView = value;
			}
		}

		// Token: 0x17002D33 RID: 11571
		// (get) Token: 0x0600957D RID: 38269 RVA: 0x00165994 File Offset: 0x00163B94
		// (set) Token: 0x0600957E RID: 38270 RVA: 0x001659AC File Offset: 0x00163BAC
		public XChatSmallView ChatSmallView
		{
			get
			{
				return this._XChatSmallView;
			}
			set
			{
				this._XChatSmallView = value;
			}
		}

		// Token: 0x17002D34 RID: 11572
		// (get) Token: 0x0600957F RID: 38271 RVA: 0x001659B8 File Offset: 0x00163BB8
		// (set) Token: 0x06009580 RID: 38272 RVA: 0x001659D0 File Offset: 0x00163BD0
		public XChatSettingView ChatSettingView
		{
			get
			{
				return this._XChatSettingView;
			}
			set
			{
				this._XChatSettingView = value;
			}
		}

		// Token: 0x17002D35 RID: 11573
		// (get) Token: 0x06009581 RID: 38273 RVA: 0x001659DC File Offset: 0x00163BDC
		// (set) Token: 0x06009582 RID: 38274 RVA: 0x001659F4 File Offset: 0x00163BF4
		public XChatMaqueeView ChatMaqueeView
		{
			get
			{
				return this._XChatMaqueeView;
			}
			set
			{
				this._XChatMaqueeView = value;
			}
		}

		// Token: 0x17002D36 RID: 11574
		// (get) Token: 0x06009583 RID: 38275 RVA: 0x00165A00 File Offset: 0x00163C00
		public bool onlyDisplayTeamChannel
		{
			get
			{
				XOptionsDocument specificDocument = XDocuments.GetSpecificDocument<XOptionsDocument>(XOptionsDocument.uuID);
				bool flag = specificDocument != null;
				return !flag || specificDocument.GetValue(XOptionsDefine.OD_Shield_NoTeam_Chat) != 0;
			}
		}

		// Token: 0x06009584 RID: 38276 RVA: 0x00165A38 File Offset: 0x00163C38
		public static void Execute(OnLoadedCallback callback = null)
		{
			XChatDocument.AsyncLoader.AddTask("Table/Chat", XChatDocument._chatTable, false);
			XChatDocument.AsyncLoader.AddTask("Table/ChatOpen", XChatDocument._chatOpenTabel, false);
			XChatDocument.AsyncLoader.AddTask("Table/ChatApollo", XChatDocument._chatApolloTable, false);
			XChatDocument.AsyncLoader.Execute(callback);
		}

		// Token: 0x06009585 RID: 38277 RVA: 0x00165A94 File Offset: 0x00163C94
		public ChatTable.RowData GetRawData(ChatChannelType type)
		{
			int num = XFastEnumIntEqualityComparer<ChatChannelType>.ToInt(type);
			for (int i = 0; i < XChatDocument._chatTable.Table.Length; i++)
			{
				bool flag = (ulong)XChatDocument._chatTable.Table[i].id == (ulong)((long)num);
				if (flag)
				{
					return XChatDocument._chatTable.Table[i];
				}
			}
			return XChatDocument._chatTable.Table[0];
		}

		// Token: 0x06009586 RID: 38278 RVA: 0x00165B04 File Offset: 0x00163D04
		public ChatApollo.RowData GetApollo(int speak, int music, int click)
		{
			int num = 100 * speak + 10 * music + click;
			for (int i = 0; i < XChatDocument._chatApolloTable.Table.Length; i++)
			{
				ChatApollo.RowData rowData = XChatDocument._chatApolloTable.Table[i];
				int num2 = 100 * rowData.speak + 10 * rowData.music + rowData.click;
				bool flag = num2 == num;
				if (flag)
				{
					return rowData;
				}
			}
			return null;
		}

		// Token: 0x06009587 RID: 38279 RVA: 0x00114AD5 File Offset: 0x00112CD5
		protected override void EventSubscribe()
		{
			base.EventSubscribe();
		}

		// Token: 0x06009588 RID: 38280 RVA: 0x00165B7C File Offset: 0x00163D7C
		public override void OnEnterSceneFinally()
		{
			base.OnEnterSceneFinally();
			DlgBase<XChatView, XChatBehaviour>.singleton.cacheShow = false;
			bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
			if (flag)
			{
				XSingleton<XChatIFlyMgr>.singleton.EnableAutoPlay(true);
			}
			bool flag2 = this.recentSendmsg.Count <= 0;
			if (flag2)
			{
				this.recentSendmsg = XSingleton<XGlobalConfig>.singleton.GetStringList("ChatArray");
			}
			bool flag3 = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
			if (flag3)
			{
				bool flag4 = !XChatDocument.m_ApolloInited;
				if (flag4)
				{
					RpcC2G_QueryClientIp rpc = new RpcC2G_QueryClientIp();
					XSingleton<XClientNetwork>.singleton.Send(rpc);
				}
				DlgBase<ReplaykitDlg, ReplayBehaviour>.singleton.CheckShow();
				XChatDocument.m_AnswerUseApollo = (int.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("UseApollo")) == 1);
				DlgBase<XChatMaqueeView, XChatMaqueeBehaviour>.singleton.SetMaqueeSwitch(true);
			}
		}

		// Token: 0x06009589 RID: 38281 RVA: 0x00165C58 File Offset: 0x00163E58
		public override void OnGamePause(bool pause)
		{
			base.OnGamePause(pause);
			DlgBase<BarrageDlg, BarrageBehaviour>.singleton.OnFouceGame(pause);
			bool flag = !pause;
			if (flag)
			{
				DlgBase<ReplaykitDlg, ReplayBehaviour>.singleton.ResumeReplay();
			}
			DlgBase<WebView, WebViewBehaviour>.singleton.OnScreenLock(pause);
		}

		// Token: 0x0600958A RID: 38282 RVA: 0x00165C9C File Offset: 0x00163E9C
		public override void OnLeaveScene()
		{
			base.OnLeaveScene();
			bool flag = DlgBase<XChatView, XChatBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<XChatView, XChatBehaviour>.singleton.SetVisibleWithAnimation(false, null);
			}
			XSingleton<XChatIFlyMgr>.singleton.OnCloseWebView();
		}

		// Token: 0x0600958B RID: 38283 RVA: 0x000FEEFC File Offset: 0x000FD0FC
		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
		}

		// Token: 0x0600958C RID: 38284 RVA: 0x00165CDC File Offset: 0x00163EDC
		public override void PostUpdate(float fDeltaT)
		{
			bool flag = this.ChatMaqueeView != null;
			if (flag)
			{
				this.ChatMaqueeView.UpdateMaquee(fDeltaT);
			}
		}

		// Token: 0x0600958D RID: 38285 RVA: 0x00165D04 File Offset: 0x00163F04
		public override void Update(float fDeltaT)
		{
			bool flag = XChatDocument.m_ProcessListSmall.Count > 0;
			if (flag)
			{
				for (int i = 0; i < XChatDocument.m_ProcessListSmall.Count; i++)
				{
					this.AddSmallChatInfo(XChatDocument.m_ProcessListSmall[i]);
				}
				DlgBase<XChatSmallView, XChatSmallBehaviour>.singleton.OnReceieveChatInfos(XChatDocument.m_ProcessListSmall);
				XChatDocument.m_ProcessListSmall.Clear();
			}
		}

		// Token: 0x0600958E RID: 38286 RVA: 0x00165D70 File Offset: 0x00163F70
		private void HanderSereverChatinfo(KKSG.ChatInfo info)
		{
			bool flag = info == null;
			if (!flag)
			{
				bool flag2 = info.source != null;
				if (flag2)
				{
					bool flag3 = !DlgBase<XFriendsView, XFriendsBehaviour>.singleton.IsBlock(info.source.roleid);
					if (flag3)
					{
						this.HandlerReceiveChatInfo(info);
					}
				}
				else
				{
					bool flag4 = info != null && XSingleton<XAttributeMgr>.singleton.XPlayerData != null && info.level <= XSingleton<XAttributeMgr>.singleton.XPlayerData.Level;
					if (flag4)
					{
						this.HandlerReceiveChatInfo(info);
					}
				}
			}
		}

		// Token: 0x0600958F RID: 38287 RVA: 0x00165DF8 File Offset: 0x00163FF8
		public override void OnAttachToHost(XObject host)
		{
			base.OnAttachToHost(host);
			int @int = XSingleton<XGlobalConfig>.singleton.GetInt("BroadcastOpen");
			PlayerPrefs.SetInt("BroadcastOpen", @int);
			XChatDocument.is_delete_audio = (int.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("IsDeleteAudio")) == 1);
			this.color_r1 = XSingleton<XGlobalConfig>.singleton.GetValue("Chat_R1");
			this.color_r2 = XSingleton<XGlobalConfig>.singleton.GetValue("Chat_R2");
			this.color_g = XSingleton<XGlobalConfig>.singleton.GetValue("Chat_G");
			this.color_n = XSingleton<XGlobalConfig>.singleton.GetValue("Chat_N");
			this.color_dg = XSingleton<XGlobalConfig>.singleton.GetValue("Chat_DG");
		}

		// Token: 0x06009590 RID: 38288 RVA: 0x00165EAF File Offset: 0x001640AF
		public override void OnDetachFromHost()
		{
			this.OnClearAllData();
			this.firstIn = true;
			DlgBase<BroadMiniDlg, BroadcastMiniBehaviour>.singleton.StopBroad();
			DlgBase<ReplaykitDlg, ReplayBehaviour>.singleton.OnStopClick(null);
		}

		// Token: 0x06009591 RID: 38289 RVA: 0x00165ED8 File Offset: 0x001640D8
		public void SendOfflineMsg()
		{
			bool flag = this.firstIn;
			if (flag)
			{
				this.ClearAllData();
				PtcC2M_LoadOfflineChatNtf ptcC2M_LoadOfflineChatNtf = new PtcC2M_LoadOfflineChatNtf();
				ptcC2M_LoadOfflineChatNtf.Data.roleID = XSingleton<XAttributeMgr>.singleton.XPlayerData.RoleID;
				XSingleton<XClientNetwork>.singleton.Send(ptcC2M_LoadOfflineChatNtf);
				this.firstIn = false;
			}
		}

		// Token: 0x06009592 RID: 38290 RVA: 0x00165F30 File Offset: 0x00164130
		public void ClearRoleMsg(ulong roleid)
		{
			List<ChatInfo> list;
			XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.World, out list);
			List<ChatInfo> list2;
			XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Guild, out list2);
			List<ChatInfo> list3;
			XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Team, out list3);
			List<ChatInfo> list4;
			XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Spectate, out list4);
			List<ChatInfo> list5;
			XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Friends, out list5);
			bool flag = list != null;
			if (flag)
			{
				this.RemveRoleMsg(roleid, list);
			}
			bool flag2 = list2 != null;
			if (flag2)
			{
				this.RemveRoleMsg(roleid, list2);
			}
			bool flag3 = list3 != null;
			if (flag3)
			{
				this.RemveRoleMsg(roleid, list3);
			}
			bool flag4 = list4 != null;
			if (flag4)
			{
				this.RemveRoleMsg(roleid, list4);
			}
			bool flag5 = list5 != null;
			if (flag5)
			{
				this.RemveRoleMsg(roleid, list5);
			}
			bool flag6 = XChatDocument.offlineProcessList != null;
			if (flag6)
			{
				this.RemveRoleMsg(roleid, XChatDocument.offlineProcessList);
			}
			bool flag7 = XChatDocument.m_ChatSmallList != null;
			if (flag7)
			{
				this.RemveRoleMsg(roleid, XChatDocument.m_ChatSmallList);
			}
			bool flag8 = XChatDocument.m_ProcessListSmall != null;
			if (flag8)
			{
				this.RemveRoleMsg(roleid, XChatDocument.m_ProcessListSmall);
			}
			this.ChatView.RefreshLoopScroll(this.ChatView.activeChannelType);
			bool flag9 = this.ChatSmallView.IsVisible();
			if (flag9)
			{
				this.ChatSmallView.ShowCacheMsg();
			}
		}

		// Token: 0x06009593 RID: 38291 RVA: 0x0016606C File Offset: 0x0016426C
		private void RemveRoleMsg(ulong roleid, List<ChatInfo> list)
		{
			bool flag = list != null;
			if (flag)
			{
				for (int i = list.Count - 1; i >= 0; i--)
				{
					bool flag2 = list[i].mSenderId == roleid;
					if (flag2)
					{
						list.RemoveAt(i);
					}
				}
			}
		}

		// Token: 0x06009594 RID: 38292 RVA: 0x001660C0 File Offset: 0x001642C0
		public void ReceiveOfflineMsg(PtcM2C_MCChatOffLineNotify roPtc)
		{
			DlgBase<XChatSmallView, XChatSmallBehaviour>.singleton.CacheMsg();
			List<KKSG.ChatInfo> list = new List<KKSG.ChatInfo>();
			bool flag = !DlgBase<XChatSmallView, XChatSmallBehaviour>.singleton.IsInited;
			if (flag)
			{
				for (int i = 0; i < roPtc.Data.rolechat.Count; i++)
				{
					list.Add(roPtc.Data.rolechat[i]);
				}
				for (int j = 0; j < roPtc.Data.guildchat.Count; j++)
				{
					list.Add(roPtc.Data.guildchat[j]);
				}
				for (int k = 0; k < roPtc.Data.teamchat.Count; k++)
				{
					list.Add(roPtc.Data.teamchat[k]);
				}
				for (int l = 0; l < roPtc.Data.worldchat.Count; l++)
				{
					list.Add(roPtc.Data.worldchat[l]);
				}
				for (int m = 0; m < roPtc.Data.partnerchat.Count; m++)
				{
					list.Add(roPtc.Data.partnerchat[m]);
				}
				for (int n = 0; n < roPtc.Data.groupchat.Count; n++)
				{
					list.Add(roPtc.Data.groupchat[n]);
				}
				list.Sort(new Comparison<KKSG.ChatInfo>(this.SortOfflineData));
				for (int num = 0; num < list.Count; num++)
				{
					this.HanderSereverChatinfo(list[num]);
				}
				this.HandlerOfflineFriend(roPtc.Data.privatechatlist);
			}
		}

		// Token: 0x06009595 RID: 38293 RVA: 0x001662C0 File Offset: 0x001644C0
		private int SortOfflineData(KKSG.ChatInfo x, KKSG.ChatInfo y)
		{
			return x.time.CompareTo(y.time);
		}

		// Token: 0x06009596 RID: 38294 RVA: 0x001662E6 File Offset: 0x001644E6
		public void OnReceiveChatInfo(KKSG.ChatInfo info)
		{
			this.HanderSereverChatinfo(info);
		}

		// Token: 0x06009597 RID: 38295 RVA: 0x001662F4 File Offset: 0x001644F4
		private ChatFriendData Chatinfo2FriendData(ChatSource friend, uint time)
		{
			return new ChatFriendData
			{
				isfriend = DlgBase<XFriendsView, XFriendsBehaviour>.singleton.IsMyFriend(friend.roleid),
				name = friend.name,
				powerpoint = friend.powerpoint,
				profession = friend.profession,
				viplevel = friend.viplevel,
				roleid = friend.roleid,
				setid = ((friend.pre != null) ? friend.pre.setid : new List<uint>()),
				msgtime = this.startTime.AddSeconds(time)
			};
		}

		// Token: 0x06009598 RID: 38296 RVA: 0x00166394 File Offset: 0x00164594
		private void HandlerOfflineFriend(PrivateChatList friends)
		{
			bool flag = friends != null && friends.rolelist != null;
			if (flag)
			{
				for (int i = 0; i < friends.rolelist.Count; i++)
				{
					ChatFriendData chatFriendData = new ChatFriendData();
					XPlayerAttributes xplayerData = XSingleton<XAttributeMgr>.singleton.XPlayerData;
					bool flag2 = friends.rolelist[i] != null && xplayerData != null && friends.rolelist[i].roleid != xplayerData.RoleID;
					if (flag2)
					{
						chatFriendData = this.Chatinfo2FriendData(friends.rolelist[i], friends.lastChatTime[i]);
						chatFriendData.hasOfflineRead = friends.hasOfflineChat[i];
						this.ChatFriendList.Add(chatFriendData);
					}
				}
			}
			this.RemoveBlockFriends();
		}

		// Token: 0x06009599 RID: 38297 RVA: 0x0016646C File Offset: 0x0016466C
		public void SetFriendRelation(ulong uid, bool isfriend)
		{
			for (int i = 0; i < this.ChatFriendList.Count; i++)
			{
				bool flag = this.ChatFriendList[i].roleid == uid;
				if (flag)
				{
					this.ChatFriendList[i].isfriend = isfriend;
					break;
				}
			}
		}

		// Token: 0x0600959A RID: 38298 RVA: 0x001664C4 File Offset: 0x001646C4
		public void OnReceiveChatSmallInfo(ChatInfo info)
		{
			bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.World && this.onlyDisplayTeamChannel && info.mChannelId != ChatChannelType.Team && info.mChannelId != ChatChannelType.Curr && info.mChannelId != ChatChannelType.Battle;
			if (!flag)
			{
				XChatDocument.m_ProcessListSmall.Add(info);
			}
		}

		// Token: 0x0600959B RID: 38299 RVA: 0x00166524 File Offset: 0x00164724
		private void CacheRecentSendmsg(string str)
		{
			bool flag = !this.recentSendmsg.Contains(str);
			if (flag)
			{
				bool flag2 = this.recentSendmsg.Count > 10;
				if (flag2)
				{
					this.recentSendmsg.RemoveAt(0);
				}
				this.recentSendmsg.Add(str);
			}
		}

		// Token: 0x0600959C RID: 38300 RVA: 0x00166574 File Offset: 0x00164774
		private void CacheRecentChatinfo(ChatInfo info)
		{
			bool flag = XChatDocument.offlineProcessList.Count > 10;
			if (flag)
			{
				XChatDocument.offlineProcessList.RemoveRange(0, XChatDocument.offlineProcessList.Count - 10);
			}
			XChatDocument.offlineProcessList.Add(info);
		}

		// Token: 0x0600959D RID: 38301 RVA: 0x001665BC File Offset: 0x001647BC
		public bool OnJoinTeam(XEventArgs args)
		{
			return true;
		}

		// Token: 0x0600959E RID: 38302 RVA: 0x001665D0 File Offset: 0x001647D0
		public bool OnLeaveTeam(XEventArgs args)
		{
			return true;
		}

		// Token: 0x0600959F RID: 38303 RVA: 0x001665E4 File Offset: 0x001647E4
		public ChatFriendData FindFriendData(ulong uid)
		{
			for (int i = 0; i < this.ChatFriendList.Count; i++)
			{
				bool flag = this.ChatFriendList[i].roleid == uid;
				if (flag)
				{
					return this.ChatFriendList[i];
				}
			}
			return null;
		}

		// Token: 0x060095A0 RID: 38304 RVA: 0x0016663C File Offset: 0x0016483C
		public void RemoveBlockFriends()
		{
			for (int i = this.ChatFriendList.Count - 1; i >= 0; i--)
			{
				ChatFriendData chatFriendData = this.ChatFriendList[i];
				bool flag = DlgBase<XFriendsView, XFriendsBehaviour>.singleton.IsBlock(chatFriendData.roleid);
				if (flag)
				{
					this.ChatFriendList.RemoveAt(i);
				}
			}
		}

		// Token: 0x060095A1 RID: 38305 RVA: 0x0016669B File Offset: 0x0016489B
		public void RemoveFriend(ulong uid)
		{
			this.SetFriendRelation(uid, false);
		}

		// Token: 0x060095A2 RID: 38306 RVA: 0x001666A7 File Offset: 0x001648A7
		public void RemoveStranger(ulong uid)
		{
			this.SetFriendRelation(uid, true);
		}

		// Token: 0x060095A3 RID: 38307 RVA: 0x0016669B File Offset: 0x0016489B
		public void AddStranger(ulong uid)
		{
			this.SetFriendRelation(uid, false);
		}

		// Token: 0x060095A4 RID: 38308 RVA: 0x001666B4 File Offset: 0x001648B4
		public List<ChatInfo> GetChatInfoList(ChatChannelType channelType)
		{
			List<ChatInfo> result = null;
			XChatDocument.m_ChatDic.TryGetValue(channelType, out result);
			return result;
		}

		// Token: 0x060095A5 RID: 38309 RVA: 0x001666D8 File Offset: 0x001648D8
		public DateTime GetFriendChatInfoTime(ulong uid)
		{
			DateTime dateTime = DateTime.Today;
			List<ChatInfo> friendChatInfoList = this.GetFriendChatInfoList(uid);
			for (int i = 0; i < friendChatInfoList.Count; i++)
			{
				bool flag = friendChatInfoList[i].mTime.CompareTo(dateTime) > 0;
				if (flag)
				{
					dateTime = friendChatInfoList[i].mTime;
				}
			}
			return dateTime;
		}

		// Token: 0x060095A6 RID: 38310 RVA: 0x0016673C File Offset: 0x0016493C
		public List<ChatInfo> GetFriendChatInfoList(ulong uid)
		{
			List<ChatInfo> list = null;
			List<ChatInfo> list2 = new List<ChatInfo>();
			XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Friends, out list);
			bool flag = list != null;
			if (flag)
			{
				for (int i = 0; i < list.Count; i++)
				{
					XPlayerAttributes xplayerData = XSingleton<XAttributeMgr>.singleton.XPlayerData;
					bool flag2 = xplayerData != null;
					if (flag2)
					{
						bool flag3 = list[i].mSenderId == xplayerData.RoleID && list[i].mReceiverId == uid;
						bool flag4 = list[i].mReceiverId == xplayerData.RoleID && list[i].mSenderId == uid;
						bool flag5 = flag4 || flag3;
						if (flag5)
						{
							list2.Add(list[i]);
						}
					}
				}
			}
			return list2;
		}

		// Token: 0x060095A7 RID: 38311 RVA: 0x0016681C File Offset: 0x00164A1C
		public List<ChatInfo> GetGroupChatInfoList(ulong groupid)
		{
			List<ChatInfo> list = null;
			List<ChatInfo> list2 = new List<ChatInfo>();
			XChatDocument.m_ChatDic.TryGetValue(ChatChannelType.Group, out list);
			bool flag = list != null;
			if (flag)
			{
				int i = 0;
				int count = list.Count;
				while (i < count)
				{
					bool flag2 = list[i].group != null && list[i].group.groupchatID == groupid;
					if (flag2)
					{
						list2.Add(list[i]);
					}
					i++;
				}
			}
			return list2;
		}

		// Token: 0x060095A8 RID: 38312 RVA: 0x001668AC File Offset: 0x00164AAC
		public ChatInfo GetChatInfoById(int id)
		{
			List<ChatInfo> list = null;
			for (ChatChannelType chatChannelType = ChatChannelType.World; chatChannelType <= ChatChannelType.ChannelNum; chatChannelType++)
			{
				XChatDocument.m_ChatDic.TryGetValue(chatChannelType, out list);
				bool flag = list != null;
				if (flag)
				{
					for (int i = 0; i < list.Count; i++)
					{
						bool flag2 = list[i].id == id;
						if (flag2)
						{
							return list[i];
						}
					}
				}
			}
			return null;
		}

		// Token: 0x060095A9 RID: 38313 RVA: 0x0016692C File Offset: 0x00164B2C
		private string ReplaceRoleName(string name)
		{
			bool flag = name.Length > 3;
			if (flag)
			{
				name = name.Remove(name.Length - 2, 2);
				name = name.Insert(name.Length, "**");
			}
			else
			{
				bool flag2 = name.Length == 3;
				if (flag2)
				{
					name = name.Remove(name.Length - 1, 1);
					name = name.Insert(name.Length, "*");
				}
			}
			return name;
		}

		// Token: 0x060095AA RID: 38314 RVA: 0x001669A8 File Offset: 0x00164BA8
		public string ProcessText(KKSG.ChatInfo serverChatInfo)
		{
			int num = 0;
			int num2 = XFastEnumIntEqualityComparer<ChatChannelType>.ToInt(ChatChannelType.System);
			int num3 = XFastEnumIntEqualityComparer<ChatChannelType>.ToInt(ChatChannelType.System);
			for (int i = 0; i < serverChatInfo.param.Count; i++)
			{
				ChatParam chatParam = serverChatInfo.param[i];
				bool flag = chatParam == null;
				if (!flag)
				{
					for (int j = 0; j < serverChatInfo.info.Length; j++)
					{
						bool flag2 = serverChatInfo.info[j] == '$' && serverChatInfo.info.Length >= j + 2;
						if (flag2)
						{
							string text = "";
							bool flag3 = chatParam.role != null && serverChatInfo.info[j + 1] == 'R';
							if (flag3)
							{
								string name = chatParam.role.name;
								bool flag4 = (long)XFastEnumIntEqualityComparer<ChatChannelType>.ToInt(ChatChannelType.System) == (long)((ulong)serverChatInfo.channel);
								if (flag4)
								{
									text = name;
								}
								else
								{
									bool flag5 = chatParam.role.uniqueid == XSingleton<XAttributeMgr>.singleton.XPlayerData.RoleID;
									if (flag5)
									{
										text = this.color_r1 + name + "[-]";
									}
									else
									{
										text = this.color_r2 + name + "[-]";
									}
								}
								num = (int)(chatParam.role.profession % 10U - 1U);
							}
							else
							{
								bool flag6 = chatParam.item != null && serverChatInfo.info[j + 1] == 'I';
								if (flag6)
								{
									ItemList.RowData itemConf = XBagDocument.GetItemConf((int)chatParam.item.item.itemID);
									bool flag7 = itemConf == null;
									if (flag7)
									{
										XSingleton<XDebug>.singleton.AddErrorLog("itemid: ", chatParam.item.item.itemID.ToString(), " content:", serverChatInfo.info, null, null);
									}
									else
									{
										bool flag8 = (long)XFastEnumIntEqualityComparer<ChatChannelType>.ToInt(ChatChannelType.System) == (long)((ulong)serverChatInfo.channel);
										if (flag8)
										{
											bool flag9 = itemConf != null;
											if (flag9)
											{
												bool flag10 = XBagDocument.GetItemConf((int)chatParam.item.item.itemID).ItemName.Length > num;
												if (flag10)
												{
													text = chatParam.item.item.itemCount.ToString() + itemConf.NumberName + itemConf.ItemName[num];
												}
												else
												{
													text = chatParam.item.item.itemCount.ToString() + itemConf.NumberName + itemConf.ItemName[0];
												}
											}
										}
										else
										{
											int itemQuality = (int)XBagDocument.GetItemConf((int)chatParam.item.item.itemID).ItemQuality;
											string itemQualityColorStr = XSingleton<UiUtility>.singleton.GetItemQualityColorStr(itemQuality);
											bool flag11 = itemConf != null;
											if (flag11)
											{
												bool flag12 = XBagDocument.GetItemConf((int)chatParam.item.item.itemID).ItemName.Length > 1;
												if (flag12)
												{
													text = string.Concat(new string[]
													{
														"[",
														itemQualityColorStr,
														"]",
														chatParam.item.item.itemCount.ToString(),
														itemConf.NumberName,
														itemConf.ItemName[num],
														"[-]"
													});
												}
												else
												{
													text = string.Concat(new string[]
													{
														"[",
														itemQualityColorStr,
														"]",
														chatParam.item.item.itemCount.ToString(),
														itemConf.NumberName,
														itemConf.ItemName[0],
														"[-]"
													});
												}
											}
										}
									}
								}
								else
								{
									bool flag13 = chatParam.num != null && serverChatInfo.info[j + 1] == 'N';
									if (flag13)
									{
										bool flag14 = (long)XFastEnumIntEqualityComparer<ChatChannelType>.ToInt(ChatChannelType.System) == (long)((ulong)serverChatInfo.channel);
										if (flag14)
										{
											text = chatParam.num.num.ToString();
										}
										else
										{
											text = this.color_n + chatParam.num.num.ToString() + "[-]";
										}
									}
									else
									{
										bool flag15 = chatParam.team != null && serverChatInfo.info[j + 1] == 'T';
										if (flag15)
										{
											text = XLabelSymbolHelper.FormatTeam(chatParam.team.teamname, (int)chatParam.team.teamid, chatParam.team.expeditionid);
										}
										else
										{
											bool flag16 = chatParam.guild != null && serverChatInfo.info[j + 1] == 'G';
											if (flag16)
											{
												text = this.color_g + chatParam.guild.guildname.ToString() + "[-]";
											}
											else
											{
												bool flag17 = chatParam.link != null && serverChatInfo.info[j + 1] == 'L';
												if (flag17)
												{
													XInvitationDocument specificDocument = XDocuments.GetSpecificDocument<XInvitationDocument>(XInvitationDocument.uuID);
													text = specificDocument.ParseLink(chatParam);
												}
												else
												{
													bool flag18 = chatParam.dragonguild != null && serverChatInfo.info[j + 1] == 'D';
													if (flag18)
													{
														text = this.color_dg + chatParam.dragonguild.dragonguildname.ToString() + "[-]";
													}
												}
											}
										}
									}
								}
							}
							string value = serverChatInfo.info.Substring(0, j);
							string value2 = serverChatInfo.info.Substring(j + 2, serverChatInfo.info.Length - (j + 2));
							text = text.Replace("$", "%^&%");
							StringBuilder stringBuilder = new StringBuilder();
							stringBuilder.Append(value);
							stringBuilder.Append(text);
							stringBuilder.Append(value2);
							serverChatInfo.info = stringBuilder.ToString();
							break;
						}
					}
				}
			}
			return serverChatInfo.info.Replace("%^&%", "$");
		}

		// Token: 0x060095AB RID: 38315 RVA: 0x00166FD8 File Offset: 0x001651D8
		private ulong GetFriendID(ChatInfo chatInfo)
		{
			XPlayerAttributes xplayerData = XSingleton<XAttributeMgr>.singleton.XPlayerData;
			bool flag = xplayerData != null && chatInfo != null;
			ulong result;
			if (flag)
			{
				result = ((chatInfo.mSenderId != xplayerData.RoleID) ? chatInfo.mSenderId : chatInfo.mReceiverId);
			}
			else
			{
				result = 0UL;
			}
			return result;
		}

		// Token: 0x060095AC RID: 38316 RVA: 0x00167024 File Offset: 0x00165224
		public void RefreshSelfMemberPriviligeInfo(uint payMemberID)
		{
			List<ChatChannelType> list = new List<ChatChannelType>
			{
				ChatChannelType.World,
				ChatChannelType.Guild,
				ChatChannelType.Curr,
				ChatChannelType.Team
			};
			for (int i = 0; i < list.Count; i++)
			{
				List<ChatInfo> list2 = null;
				XChatDocument.m_ChatDic.TryGetValue(list[i], out list2);
				bool flag = list2 != null;
				if (flag)
				{
					for (int j = 0; j < list2.Count; j++)
					{
						bool isSelfSender = list2[j].isSelfSender;
						if (isSelfSender)
						{
							list2[j].mSenderPaymemberid = payMemberID;
						}
					}
					this.ChatView.RefreshLoopScroll(list[i]);
				}
			}
		}

		// Token: 0x060095AD RID: 38317 RVA: 0x001670E8 File Offset: 0x001652E8
		public List<ChatInfo> AddChatInfo(ChatInfo chatInfo, ChatChannelType channelId)
		{
			List<ChatInfo> list = null;
			XChatDocument.m_ChatDic.TryGetValue(channelId, out list);
			bool flag = list == null;
			if (flag)
			{
				list = new List<ChatInfo>();
				list.Add(chatInfo);
				XChatDocument.m_ChatDic.Add(channelId, list);
			}
			else
			{
				bool flag2 = list.Count > 200;
				if (flag2)
				{
					list.RemoveAt(0);
				}
				list.Add(chatInfo);
			}
			bool flag3 = channelId == ChatChannelType.Friends;
			if (flag3)
			{
				ulong friendID = this.GetFriendID(chatInfo);
				ChatFriendData chatFriendData = this.FindFriendData(friendID);
				bool flag4 = chatFriendData == null && DlgBase<XChatSmallView, XChatSmallBehaviour>.singleton.IsInited;
				if (flag4)
				{
					this.AddChatinfo2FriendList(chatInfo);
				}
				bool flag5 = chatFriendData != null;
				if (flag5)
				{
					chatFriendData.msgtime = DateTime.Now;
				}
				list = this.GetFriendChatInfoList(this.ChatView.ChatFriendId);
			}
			else
			{
				bool flag6 = channelId == ChatChannelType.Group;
				if (flag6)
				{
					GroupChatDocument specificDocument = XDocuments.GetSpecificDocument<GroupChatDocument>(GroupChatDocument.uuID);
					specificDocument.AddChat2Group(chatInfo);
				}
			}
			return list;
		}

		// Token: 0x060095AE RID: 38318 RVA: 0x001671E4 File Offset: 0x001653E4
		public void AddChatinfo2FriendList(ChatInfo info)
		{
			ChatFriendData chatFriendData = new ChatFriendData();
			chatFriendData.msgtime = info.mTime;
			bool flag = !info.isSelfSender;
			if (flag)
			{
				chatFriendData.name = info.mSenderName;
				chatFriendData.roleid = info.mSenderId;
				chatFriendData.powerpoint = info.mSenderPowerPoint;
				chatFriendData.profession = info.mServerProfession;
				chatFriendData.viplevel = info.mSenderVip;
				chatFriendData.setid = ((info.payConsume != null) ? info.payConsume.setid : new List<uint>());
				bool flag2 = info.payConsume != null;
				if (flag2)
				{
					chatFriendData.setid = info.payConsume.setid;
				}
				chatFriendData.isfriend = DlgBase<XFriendsView, XFriendsBehaviour>.singleton.IsMyFriend(info.mSenderId);
			}
			else
			{
				chatFriendData.name = info.mReceiverName;
				chatFriendData.roleid = info.mReceiverId;
				chatFriendData.powerpoint = info.mReciverPowerPoint;
				chatFriendData.profession = info.mRecieverProfession;
				chatFriendData.viplevel = info.mReceiverVip;
				chatFriendData.isfriend = DlgBase<XFriendsView, XFriendsBehaviour>.singleton.IsMyFriend(info.mReceiverId);
			}
			bool flag3 = !this.ContainRole(chatFriendData.roleid);
			if (flag3)
			{
				this.ChatFriendList.Add(chatFriendData);
			}
		}

		// Token: 0x060095AF RID: 38319 RVA: 0x00167320 File Offset: 0x00165520
		private bool ContainRole(ulong roleID)
		{
			for (int i = 0; i < this.ChatFriendList.Count; i++)
			{
				bool flag = this.ChatFriendList[i].roleid == roleID;
				if (flag)
				{
					return true;
				}
			}
			return false;
		}

		// Token: 0x060095B0 RID: 38320 RVA: 0x0016736C File Offset: 0x0016556C
		private void HandlerMaqueeInfo(KKSG.ChatInfo serverChatInfo)
		{
			for (int i = 0; i < serverChatInfo.param.Count; i++)
			{
				ChatParam chatParam = serverChatInfo.param[i];
				bool flag = chatParam == null;
				if (!flag)
				{
					for (int j = 0; j < serverChatInfo.info.Length; j++)
					{
						bool flag2 = serverChatInfo.info[j] == '$' && serverChatInfo.info.Length >= j + 2;
						if (flag2)
						{
							bool flag3 = chatParam.role != null && serverChatInfo.info[j + 1] == 'R';
							if (flag3)
							{
								chatParam.role.name = this.ReplaceRoleName(chatParam.role.name);
							}
						}
					}
				}
			}
		}

		// Token: 0x060095B1 RID: 38321 RVA: 0x0016744C File Offset: 0x0016564C
		public void HandlerReceiveChatInfo(KKSG.ChatInfo serverChatInfo)
		{
			bool flag = serverChatInfo.info == null || serverChatInfo.info == "" || XSingleton<XAttributeMgr>.singleton.XPlayerData == null;
			if (!flag)
			{
				string info = serverChatInfo.info;
				bool flag2 = serverChatInfo.channel == 5U || serverChatInfo.channel == 6U;
				if (flag2)
				{
					this.HandlerMaqueeInfo(serverChatInfo);
					serverChatInfo.info = this.ProcessText(serverChatInfo);
					DlgBase<XChatMaqueeView, XChatMaqueeBehaviour>.singleton.ReceiveChatInfo(serverChatInfo);
					serverChatInfo.channel = (uint)XFastEnumIntEqualityComparer<ChatChannelType>.ToInt(ChatChannelType.System);
					serverChatInfo.info = info;
				}
				serverChatInfo.info = this.ProcessText(serverChatInfo);
				ChatInfo chatInfo = new ChatInfo();
				chatInfo.mTime = this.startTime.AddSeconds(serverChatInfo.time);
				chatInfo.mAudioId = serverChatInfo.audioUid;
				chatInfo.mAudioTime = serverChatInfo.audioLen;
				chatInfo.voice = chatInfo.GetVoice(serverChatInfo.audioUid, serverChatInfo.audioLen);
				chatInfo.mRegression = false;
				chatInfo.CampDuelID = 0U;
				chatInfo.isAudioPlayed = !DlgBase<XChatSmallView, XChatSmallBehaviour>.singleton.IsInited;
				chatInfo.isUIShowed = !DlgBase<XChatSmallView, XChatSmallBehaviour>.singleton.IsInited;
				bool flag3 = serverChatInfo.source != null;
				if (flag3)
				{
					chatInfo.mSenderName = serverChatInfo.source.name.TrimEnd(new char[0]);
					chatInfo.mSenderId = serverChatInfo.source.roleid;
					chatInfo.mSenderVip = serverChatInfo.source.viplevel;
					chatInfo.mSenderPaymemberid = serverChatInfo.source.paymemberid;
					chatInfo.mServerProfession = serverChatInfo.source.profession;
					chatInfo.mSenderPowerPoint = serverChatInfo.source.powerpoint;
					chatInfo.mCoverDesignationID = serverChatInfo.source.coverDesignationID;
					chatInfo.mSpecialDesignation = serverChatInfo.source.desname;
					chatInfo.militaryRank = serverChatInfo.source.military_rank;
					chatInfo.payConsume = serverChatInfo.source.pre;
					chatInfo.mHeroID = serverChatInfo.source.heroid;
					chatInfo.group = serverChatInfo.groupchatinfo;
					chatInfo.mRegression = serverChatInfo.source.isBackFlow;
					chatInfo.CampDuelID = serverChatInfo.source.campDuelID;
				}
				else
				{
					bool flag4 = serverChatInfo.channel == 7U && this.CheckTeam();
					if (flag4)
					{
						chatInfo.mSenderId = 0UL;
						chatInfo.mSenderName = XStringDefineProxy.GetString("CHAT_TEAM_NEW");
						chatInfo.mSenderVip = 1U;
						chatInfo.mSenderPaymemberid = 0U;
					}
					else
					{
						bool flag5 = serverChatInfo.channel == 2U && this.CheckGuild();
						if (flag5)
						{
							chatInfo.mSenderId = 0UL;
							chatInfo.mSenderName = XStringDefineProxy.GetString("CHAT_GUILD_NEW");
							chatInfo.mSenderVip = 1U;
							chatInfo.mSenderPaymemberid = 0U;
						}
					}
				}
				bool flag6 = serverChatInfo.destList != null && serverChatInfo.destList.Count > 0;
				if (flag6)
				{
					chatInfo.mReceiverId = serverChatInfo.destList[0].roleid;
					chatInfo.mReceiverName = serverChatInfo.destList[0].name;
					chatInfo.mReceiverVip = serverChatInfo.destList[0].viplevel;
					chatInfo.mRecieverProfession = serverChatInfo.destList[0].profession;
					chatInfo.mReciverPowerPoint = serverChatInfo.destList[0].powerpoint;
				}
				else
				{
					bool flag7 = serverChatInfo.dest != null && serverChatInfo.dest.roleid.Count > 0;
					if (flag7)
					{
						chatInfo.mReceiverId = serverChatInfo.dest.roleid[0];
					}
				}
				chatInfo.mContent = serverChatInfo.info;
				chatInfo.mChannelId = (ChatChannelType)serverChatInfo.channel;
				bool flag8 = chatInfo.mSenderId == XSingleton<XAttributeMgr>.singleton.XPlayerData.RoleID;
				if (flag8)
				{
					chatInfo.isSelfSender = true;
					chatInfo.mChatType = (chatInfo.isAudioChat ? ChatType.SelfVoice : ChatType.SelfText);
				}
				else
				{
					chatInfo.isSelfSender = false;
					chatInfo.mChatType = (chatInfo.isAudioChat ? ChatType.OtherVoice : ChatType.OtherText);
				}
				this.ReceiveChatInfo(chatInfo);
			}
		}

		// Token: 0x060095B2 RID: 38322 RVA: 0x00167854 File Offset: 0x00165A54
		public void ReceiveChatInfo(ChatInfo chatInfo)
		{
			bool flag = chatInfo.isAudioChat && !chatInfo.isAudioPlayed;
			if (flag)
			{
				bool isSelfSender = chatInfo.isSelfSender;
				if (isSelfSender)
				{
					XSingleton<XChatIFlyMgr>.singleton.StopAutoPlay();
					XSingleton<XChatIFlyMgr>.singleton.InsertAutoPlayList(chatInfo, true);
					return;
				}
				bool isAutoPlayEnable = XSingleton<XChatIFlyMgr>.singleton.IsAutoPlayEnable;
				if (isAutoPlayEnable)
				{
					bool flag2 = XSingleton<XChatIFlyMgr>.singleton.AddAutoPlayList(chatInfo);
					bool flag3 = !flag2;
					if (!flag3)
					{
						return;
					}
					chatInfo.isAudioPlayed = true;
				}
				chatInfo.isAudioPlayed = true;
			}
			bool isInited = DlgBase<XChatSmallView, XChatSmallBehaviour>.singleton.IsInited;
			if (isInited)
			{
				this.OnReceiveChatSmallInfo(chatInfo);
				bool flag4 = chatInfo.isSelfSender && !chatInfo.isAudioChat && !chatInfo.mContent.Contains("tm=") && !chatInfo.mContent.Contains("gd=") && !chatInfo.mContent.Contains("ui=") && !chatInfo.mContent.Contains("sp=");
				if (flag4)
				{
					this.CacheRecentSendmsg(chatInfo.mContent);
				}
				XEntity entity = XSingleton<XEntityMgr>.singleton.GetEntity(chatInfo.mSenderId);
				bool flag5 = entity != null;
				if (flag5)
				{
					XCharacterShowChatComponent xcharacterShowChatComponent = entity.GetXComponent(XCharacterShowChatComponent.uuID) as XCharacterShowChatComponent;
					bool flag6 = xcharacterShowChatComponent != null;
					if (flag6)
					{
						xcharacterShowChatComponent.AttachChatBubble();
					}
					bool flag7 = xcharacterShowChatComponent != null;
					if (flag7)
					{
						xcharacterShowChatComponent.DealWithChat(chatInfo.mContent);
					}
				}
				DlgBase<BarrageDlg, BarrageBehaviour>.singleton.RealPush(chatInfo);
			}
			this.CacheRecentChatinfo(chatInfo);
			List<ChatInfo> list = this.AddChatInfo(chatInfo, chatInfo.mChannelId);
			bool flag8 = chatInfo.mChannelId == ChatChannelType.Friends;
			if (flag8)
			{
				DlgBase<XChatView, XChatBehaviour>.singleton.ShowTabFriendRed();
			}
			bool flag9 = !this.ChatView.IsInited || !this.ChatView.IsVisible() || chatInfo.mChannelId != this.ChatView.activeChannelType;
			if (!flag9)
			{
				bool flag10 = chatInfo.mContent.IndexOf("\\n") != -1;
				if (flag10)
				{
					chatInfo.mContent = chatInfo.mContent.Replace("\\n", "/n");
				}
				this.ChatView.RefreshLoopScroll(this.ChatView.activeChannelType);
			}
		}

		// Token: 0x060095B3 RID: 38323 RVA: 0x00167A9C File Offset: 0x00165C9C
		public void ClearFriendMsg(ulong roleid)
		{
			bool flag = roleid == 0UL;
			if (flag)
			{
				this.ChatFriendList.Clear();
			}
			else
			{
				for (int i = 0; i < this.ChatFriendList.Count; i++)
				{
					bool flag2 = this.ChatFriendList[i].roleid == roleid;
					if (flag2)
					{
						this.ChatFriendList.RemoveAt(i);
					}
				}
			}
		}

		// Token: 0x060095B4 RID: 38324 RVA: 0x00167B04 File Offset: 0x00165D04
		public List<ChatInfo> GetSmallChatList()
		{
			return XChatDocument.m_ChatSmallList;
		}

		// Token: 0x060095B5 RID: 38325 RVA: 0x00167B1C File Offset: 0x00165D1C
		public void RestrainSmallChatInfoNum()
		{
			bool flag = (long)XChatDocument.m_ChatSmallList.Count > (long)((ulong)XChatSmallBehaviour.m_MaxShowMsg);
			if (flag)
			{
				XChatDocument.m_ChatSmallList.RemoveRange(0, XChatDocument.m_ChatSmallList.Count - (int)XChatSmallBehaviour.m_MaxShowMsg);
			}
		}

		// Token: 0x060095B6 RID: 38326 RVA: 0x00167B5F File Offset: 0x00165D5F
		public void AddSmallChatInfo(ChatInfo info)
		{
			XChatDocument.m_ChatSmallList.Add(info);
		}

		// Token: 0x060095B7 RID: 38327 RVA: 0x00167B70 File Offset: 0x00165D70
		public void OnClearAllData()
		{
			this.ClearAllData();
			XSingleton<XChatIFlyMgr>.singleton.EnableAutoPlay(false);
			XSingleton<XChatIFlyMgr>.singleton.StopAutoPlay();
			XSingleton<XChatIFlyMgr>.singleton.ClearPlayList();
			DlgBase<XChatSmallView, XChatSmallBehaviour>.singleton.IsInited = false;
			DlgBase<XChatView, XChatBehaviour>.singleton.ChatFriendId = 0UL;
		}

		// Token: 0x060095B8 RID: 38328 RVA: 0x00167BC0 File Offset: 0x00165DC0
		private void ClearAllData()
		{
			List<ChatChannelType> list = new List<ChatChannelType>(XChatDocument.m_ChatDic.Keys);
			for (int i = 0; i < list.Count; i++)
			{
				List<ChatInfo> list2 = XChatDocument.m_ChatDic[list[i]];
				bool flag = list2 != null;
				if (flag)
				{
					list2.Clear();
				}
			}
			XChatDocument.m_ChatSmallList.Clear();
			XChatDocument.offlineProcessList.Clear();
			XChatDocument.m_ChatDic.Clear();
			XChatDocument.m_ProcessListSmall.Clear();
		}

		// Token: 0x060095B9 RID: 38329 RVA: 0x00167C44 File Offset: 0x00165E44
		private ChatOpen.RowData ChatOpenRow(int type)
		{
			bool flag = this.openTable.Count <= 0;
			if (flag)
			{
				this.sOpenTbale.Clear();
				for (int i = 0; i < XChatDocument._chatOpenTabel.Table.Length; i++)
				{
					bool flag2 = XChatDocument._chatOpenTabel.Table[i].sceneid == 0U;
					if (flag2)
					{
						this.openTable.Add((int)XChatDocument._chatOpenTabel.Table[i].id, XChatDocument._chatOpenTabel.Table[i]);
					}
					else
					{
						bool flag3 = !this.sOpenTbale.ContainsKey(XChatDocument._chatOpenTabel.Table[i].sceneid);
						if (flag3)
						{
							this.sOpenTbale.Add(XChatDocument._chatOpenTabel.Table[i].sceneid, XChatDocument._chatOpenTabel.Table[i]);
						}
					}
				}
			}
			uint sceneID = XSingleton<XScene>.singleton.SceneID;
			bool flag4 = type < 100 && this.sOpenTbale.ContainsKey(sceneID);
			ChatOpen.RowData result;
			if (flag4)
			{
				result = this.sOpenTbale[sceneID];
			}
			else
			{
				bool flag5 = this.openTable.ContainsKey(type);
				if (flag5)
				{
					result = this.openTable[type];
				}
				else
				{
					XSingleton<XDebug>.singleton.AddErrorLog("找胡博聃，配chatopen表! new scenetype:", type.ToString(), null, null, null, null);
					result = this.openTable[1];
				}
			}
			return result;
		}

		// Token: 0x060095BA RID: 38330 RVA: 0x00167DB8 File Offset: 0x00165FB8
		public List<int> SortCommonIcons(int type)
		{
			List<int> list = new List<int>(this.ChatOpenRow(type).opens);
			bool flag = this.CheckGuild();
			bool flag2 = this.CheckTeam();
			bool flag3 = this.CheckLevelLimit(ChatChannelType.World);
			bool flag4 = list.Contains(1) && !flag3;
			if (flag4)
			{
				list.Remove(1);
			}
			bool flag5 = list.Contains(2) && !flag;
			if (flag5)
			{
				list.Remove(2);
			}
			bool flag6 = list.Contains(7) && !flag2;
			if (flag6)
			{
				list.Remove(7);
			}
			return list;
		}

		// Token: 0x060095BB RID: 38331 RVA: 0x00167E58 File Offset: 0x00166058
		public ChatOpen.RowData GetYuyinRaw(int type)
		{
			return this.ChatOpenRow(type);
		}

		// Token: 0x060095BC RID: 38332 RVA: 0x00167E74 File Offset: 0x00166074
		public ChatOpen.RowData GetBattleRaw()
		{
			return this.GetYuyinRaw((int)XSingleton<XScene>.singleton.SceneType);
		}

		// Token: 0x060095BD RID: 38333 RVA: 0x00167E98 File Offset: 0x00166098
		public List<ChatFriendData> FetchFriendsIcons()
		{
			this.ChatFriendList.Sort(XSingleton<XChatUIOP>.singleton.CompareNewMsgCb);
			return this.ChatFriendList;
		}

		// Token: 0x060095BE RID: 38334 RVA: 0x00167EC8 File Offset: 0x001660C8
		public uint GetChatMaxFriendCount(int type)
		{
			return this.ChatOpenRow(type).friends;
		}

		// Token: 0x060095BF RID: 38335 RVA: 0x00167EE8 File Offset: 0x001660E8
		public bool CheckLevelLimit(ChatChannelType type)
		{
			int key = XFastEnumIntEqualityComparer<ChatChannelType>.ToInt(type);
			XPlayerAttributes xplayerData = XSingleton<XAttributeMgr>.singleton.XPlayerData;
			bool flag = xplayerData != null;
			return flag && XChatDocument._chatTable.GetByid((uint)key).level <= xplayerData.Level;
		}

		// Token: 0x060095C0 RID: 38336 RVA: 0x00167F34 File Offset: 0x00166134
		public bool CheckGuild()
		{
			bool flag = this.guildDoc == null;
			if (flag)
			{
				this.guildDoc = XDocuments.GetSpecificDocument<XGuildDocument>(XGuildDocument.uuID);
			}
			return this.guildDoc.bInGuild;
		}

		// Token: 0x060095C1 RID: 38337 RVA: 0x00167F70 File Offset: 0x00166170
		public bool CheckTeam()
		{
			bool flag = this.teamDoc == null;
			if (flag)
			{
				this.teamDoc = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
			}
			return this.teamDoc.MyTeam != null && this.teamDoc.MyTeam.teamBrief.teamID != 0;
		}

		// Token: 0x060095C2 RID: 38338 RVA: 0x00167FC8 File Offset: 0x001661C8
		public void ReqGetFlowerLeftTime()
		{
			RpcC2G_GetFlowerLeftTime rpc = new RpcC2G_GetFlowerLeftTime();
			XSingleton<XClientNetwork>.singleton.Send(rpc);
		}

		// Token: 0x060095C3 RID: 38339 RVA: 0x00167FE8 File Offset: 0x001661E8
		public void OnGetFlowerLeftTime(GetFlowerLeftTimeRes oRes)
		{
			bool flag = oRes.errorCode == ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				XSingleton<XGameSysMgr>.singleton.GetFlowerRemainTime = (float)oRes.leftTime;
				this.getFlowerLeftTime = oRes.leftTime;
				this.canGetFlower = oRes.canGet;
				bool flag2 = !oRes.canGet;
				if (flag2)
				{
					this.getFlowerLeftTime = 0;
				}
				DlgBase<XChatView, XChatBehaviour>.singleton.OnRefreshGetFlowerInfo();
			}
		}

		// Token: 0x060095C4 RID: 38340 RVA: 0x00168050 File Offset: 0x00166250
		public void ReqGetFlower()
		{
			RpcC2G_GetFlower rpc = new RpcC2G_GetFlower();
			XSingleton<XClientNetwork>.singleton.Send(rpc);
		}

		// Token: 0x060095C5 RID: 38341 RVA: 0x00168070 File Offset: 0x00166270
		public void OnGetFlower(GetFlowerRes oRes)
		{
			bool flag = oRes.errorCode == ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				XSingleton<XGameSysMgr>.singleton.GetFlowerRemainTime = (float)oRes.leftTime;
				this.getFlowerLeftTime = oRes.leftTime;
				this.canGetFlower = oRes.canGet;
				bool flag2 = !oRes.canGet;
				if (flag2)
				{
					this.getFlowerLeftTime = 0;
				}
				DlgBase<XChatView, XChatBehaviour>.singleton.OnRefreshGetFlowerInfo();
			}
		}

		// Token: 0x040032A5 RID: 12965
		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("XChatDocument");

		// Token: 0x040032A6 RID: 12966
		private XChatView _XChatView = null;

		// Token: 0x040032A7 RID: 12967
		private XChatSmallView _XChatSmallView = null;

		// Token: 0x040032A8 RID: 12968
		private XChatSettingView _XChatSettingView = null;

		// Token: 0x040032A9 RID: 12969
		private XChatMaqueeView _XChatMaqueeView = null;

		// Token: 0x040032AA RID: 12970
		private DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));

		// Token: 0x040032AB RID: 12971
		public List<ChatFriendData> ChatFriendList = new List<ChatFriendData>();

		// Token: 0x040032AC RID: 12972
		private static Dictionary<ChatChannelType, List<ChatInfo>> m_ChatDic = new Dictionary<ChatChannelType, List<ChatInfo>>();

		// Token: 0x040032AD RID: 12973
		private const int CHAT_MEMORY_COUNT = 200;

		// Token: 0x040032AE RID: 12974
		private static List<ChatInfo> m_ChatSmallList = new List<ChatInfo>();

		// Token: 0x040032AF RID: 12975
		private static List<ChatInfo> m_ProcessListSmall = new List<ChatInfo>();

		// Token: 0x040032B0 RID: 12976
		public static List<ChatInfo> offlineProcessList = new List<ChatInfo>();

		// Token: 0x040032B1 RID: 12977
		public List<string> recentSendmsg = new List<string>();

		// Token: 0x040032B2 RID: 12978
		public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();

		// Token: 0x040032B3 RID: 12979
		public static byte[] m_ApolloKey = new byte[1024];

		// Token: 0x040032B4 RID: 12980
		public static int[] m_ApolloIPtable = new int[4];

		// Token: 0x040032B5 RID: 12981
		public static bool m_ApolloInited = false;

		// Token: 0x040032B6 RID: 12982
		public static string m_ClientIP = "127.0.0.1";

		// Token: 0x040032B7 RID: 12983
		public static int CLEAR_ENTER_AUDIO_COUNT = 5;

		// Token: 0x040032B8 RID: 12984
		public static bool is_delete_audio = true;

		// Token: 0x040032B9 RID: 12985
		public static bool m_AnswerUseApollo = true;

		// Token: 0x040032BA RID: 12986
		public static bool UseApollo = true;

		// Token: 0x040032BB RID: 12987
		public int getFlowerLeftTime;

		// Token: 0x040032BC RID: 12988
		public bool canGetFlower;

		// Token: 0x040032BD RID: 12989
		private string color_r1;

		// Token: 0x040032BE RID: 12990
		private string color_r2;

		// Token: 0x040032BF RID: 12991
		private string color_g;

		// Token: 0x040032C0 RID: 12992
		private string color_n;

		// Token: 0x040032C1 RID: 12993
		private string color_dg;

		// Token: 0x040032C2 RID: 12994
		private static ChatTable _chatTable = new ChatTable();

		// Token: 0x040032C3 RID: 12995
		private static ChatOpen _chatOpenTabel = new ChatOpen();

		// Token: 0x040032C4 RID: 12996
		public static ChatApollo _chatApolloTable = new ChatApollo();

		// Token: 0x040032C5 RID: 12997
		private static bool[] s_commonIcons = new bool[15];

		// Token: 0x040032C6 RID: 12998
		private bool firstIn = true;

		// Token: 0x040032C7 RID: 12999
		private const int MAX_RECNET_COUNT = 10;

		// Token: 0x040032C8 RID: 13000
		private const int MAX_OFFLINE_COUNT = 10;

		// Token: 0x040032C9 RID: 13001
		private Dictionary<int, ChatOpen.RowData> openTable = new Dictionary<int, ChatOpen.RowData>();

		// Token: 0x040032CA RID: 13002
		private Dictionary<uint, ChatOpen.RowData> sOpenTbale = new Dictionary<uint, ChatOpen.RowData>();

		// Token: 0x040032CB RID: 13003
		private XGuildDocument guildDoc;

		// Token: 0x040032CC RID: 13004
		private XTeamDocument teamDoc;
	}
}
